package cn.iocoder.yudao.module.energy.convert.alert;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.energy.controller.admin.alert.vo.*;
import cn.iocoder.yudao.module.energy.dal.dataobject.alert.EnergyAlertDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 预警 Convert
 *
 * @author 芋道源码
 */
@Mapper
public interface AlertConvert {

    AlertConvert INSTANCE = Mappers.getMapper(AlertConvert.class);

    EnergyAlertDO convert(AlertSaveReqVO bean);

    @Mapping(source = "level", target = "level")
    AlertRespVO convert(EnergyAlertDO bean);

    List<AlertRespVO> convertList(List<EnergyAlertDO> list);

    default PageResult<AlertRespVO> convertPage(PageResult<EnergyAlertDO> page) {
        PageResult<AlertRespVO> result = new PageResult<>();
        result.setList(convertList(page.getList()));
        result.setTotal(page.getTotal());
        return result;
    }

} 